import {Base} from '../../utils/base.js';
class Index extends Base{
  constructor()
  {
    super();
  }

  //获取首页分类
  getCategory(callback)
  {
    var that = this;
    var params={
      url:'category',
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params);
  }

  //获取首页轮播图
  getBanner(callback)
  {
    var that = this;
    var params={
      url:'banner',
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params);
  }

  //获取分类下的有限的商品
  getLimitProduct(callback)
  {
    var that = this;
    var params={
      url:'category_limit_products',
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params);
  }

  //根据分类ID获取该分类下的所有的商品
  getCategoryProducts(id,callback)
  {
    var that = this;
    var params={
      url:'all_category_product?id='+id,
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params);
  }

  //根据关键词搜索商品
  searchProduct(keyword,callback)
  {
    var that = this;
    var params={
      url:'search',
      type:'POST',
      data:{
        keyword:keyword
      },
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params);
  }
}
export {Index};